home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / prtcs155.zip / SCALL.REX < prev    next >
OS/2 REXX Batch file  |  1994-01-14  |  10KB  |  304 lines

  1. /**/
  2. v="$VER: Scall Rexx  Shelter Poll Manager  Williamson 00.98"
  3. sv=right(v,5);script='Scall'
  4. options results
  5. options failat 999
  6. signal on syntax
  7. signal on halt
  8. signal on ioerr
  9. signal on break_c
  10. signal on break_d
  11. shelter=GetClip("SHELTER")
  12. if shelter="" then do;Say "No Shelter Mailer available";EXIT;end
  13. ushelter=upper(shelter);lshelter=lower(shelter)
  14. point=ushelter=="UMBRELLA"
  15. pollwin=upper(Getclip('POLLWIN'))=="TRUE"
  16.  
  17.  parse arg args
  18.  number=""
  19.  line=""
  20.  pri=""
  21.  redialdelay=""
  22.  duration=""
  23.  crash=0;nopickup=0;manual=0
  24.  template="Site_Address/A,LINE/K,NUMBER/K,PRI/K,REDIALDELAY/K,DURATION/K,CRASH/S,NOPICKUP/S"
  25.  if ~ReadArgs(args,template) then do
  26.     say Fault(RC,script)
  27.     signal usage
  28.  end;else do
  29.     if site_address="?" then signal usage
  30.     if pri~="" then call Pragma('p',pri)
  31.     else call Pragma('p',-1)
  32.     if number~="" then do
  33.         man_number=number
  34.         manual=1
  35.     end 
  36.     if line~="" then do
  37.         requested_line=line
  38.     end;else do
  39.         if ushelter=="PORTICUS"|ushelter=="ROOF" then slave=2
  40.         else slave=1
  41.     end
  42.     noclip=0
  43.     if redialdelay="" then do
  44.         redialdelay=GetClip('REDIALDELAY')
  45.         noclip=1
  46.     end
  47.     if duration="" then duration=GetClip('CALLWINDOWMIN')
  48.  
  49.     bbs=0;fax=0;clock=0;uucp=0;ftn=0
  50.     bbs    =left(upper(site_address),3)=="BBS"
  51.     fax    =left(upper(site_address),3)=="FAX"
  52.     clock  =(~fax & ~bbs & left(upper(site_address),5)="CLOCK")
  53.     uucp   =(~fax & ~bbs &~clock) & (left(upper(site_address),2)=="UU" | datatype(right(site_address,2),'MIXED'))
  54.     ftn    =(~bbs & ~fax & ~uucp & ~clock)
  55.     if bbs | fax | clock then site_address=upper(site_address)
  56.         else if uucp then site_address=delstr(site_address,1,2)
  57.                 else site_address=make5d(site_address)
  58.     if site_address=0 then do
  59.         call PutLog('BAD site_address',10,10)
  60.         exit 10
  61.     end
  62. end
  63. if point & (bbs|uucp|clock) then address=0
  64. if site_address=0 then do
  65. call PutLog('BAD site_address:'site_address);exit 10
  66. end
  67. cs=strip(GetClip("S"||site_address))
  68. if datatype(cs)='NUM' then do
  69. call PutLog('Already calling 'site_address' Status:['cs']');exit 10
  70. end
  71. x=Pragma('p',-1)
  72. tadr=translate(site_address,"...","#:/")
  73. if pollwin then do
  74. polls=Getclip('POLLS')
  75. if polls="" then polls=1
  76. else polls=polls+1
  77. call openwin('CON:0/'80+(polls*10)'/400/60/'script 'v'sv tadr'/AUTO/INACTIVE/CLOSE/SCREEN')
  78. call SetClip('POLLS',polls)
  79. end
  80. docall=1 ; nocall=0 ; callcount=0 ; callok=0 ; retry=5 ; exitcall=10 
  81. if bbs then  call PutLog('Polling BBS 'site_address' on line' slave)
  82. else if clock then call PutLog('Polling 'site_address' on line' slave)
  83. else if uucp then call PutLog('Polling UUCP Site 'site_address' on line' slave)
  84. else do
  85.     call PutLog('Polling 'dd'#'z':'n'/'f'.'p 'on line' slave)
  86.     outdir=GetClip('OUTDIR')'/'
  87.     if exists(outdir||z'.'n'.'f'.'p'.REQ') then do
  88.         address COMMAND 'Copy 'outdir||z'.'n'.'f'.'p'.REQ' outdir||z'.'n'.'f'.'p'.REQTEMP'
  89.     end
  90. end
  91. if manual then call PutLog('Manual Poll 'man_number)
  92. callstart=time('n');callcount=0
  93. dial_from=time('s');df=left(callstart,5)
  94. dial_till=dial_from+(duration*60);dt=dial_till%(60*60)':'right('0'||strip(left(dial_till//(60*60)/60,2),T,'.') ,2)
  95.  
  96. call PutLog(site_address' Poll Window: 'df'->'dt)
  97. do while (time('s') < dial_till)
  98.     if pollwin & eof('STDOUT') then leave
  99.     callcount=callcount+1
  100.     p_stat=GetClip("S"||site_address)
  101.     call SetClip("S"||site_address,callcount)
  102.     if p_stat='abort' then do
  103.         call PutLog('User aborted poll to 'site_address' at 'left(time(),5)' on call 'callcount)
  104.         call SetClip("S"||site_address,'USER ABORT')
  105.         call callcleanup;return(exitcall)
  106.     end
  107.     d_stat=do_dial()
  108.     if d_stat=exitcall then do
  109.         call PutLog('Poll of 'site_address' terminated')
  110.         call callcleanup;return 0
  111.     end
  112.     if d_stat=callok then do
  113.         call SetClip("S"||site_address,'OK')
  114.         call PutLog('Poll of 'site_address' completed')
  115.         call callcleanup;return 0
  116.     end
  117. end
  118. if ~EOF('STDOUT') then call PutLog('Exceeded 'duration' min. call window for 'site_address', callcount:'callcount)
  119. else do
  120.     call PutLog('Poll of 'site_address' aborted')
  121.     call SetClip("S"||site_address,'abort')
  122. end
  123. call callcleanup
  124. Return 0
  125.  
  126. do_dial:
  127. if ~show('p',ushelter||slave) then do
  128. PutLog(ushelter||slave 'is not active');return(exitcall);end
  129. Address VALUE ushelter||slave
  130. 'String $(state)'
  131. ws=RESULT
  132. call Putlog(ushelter||slave 'state:'ws)
  133. wstat=upper(word(ws,1))
  134. select
  135. when wstat='EXITING' then do
  136.     call PutLog('Exiting, aborting dial 'site_address);return(exitcall)
  137. end
  138. when wstat='SESSION' then do
  139.     if find(upper(ws),upper(site_address))=0 then call PutLog('Queuing dial of 'site_address)
  140.     else do
  141.         call PutLog('Aborting call, already 'wstat site_address);return(exitcall)
  142.     end
  143. end
  144. when wstat='DIALING' then do
  145.     if find(upper(ws),upper(site_address)) ~=0 then
  146.     do
  147.         call PutLog('Aborting call, already 'wstat site_address);return(exitcall)
  148.     end
  149. end
  150. otherwise nop
  151. end
  152. call PutLog('Dialing 'site_address)
  153. Address VALUE ushelter||slave
  154. if manual then 'Set number' man_number 'MANUAL TRUE'
  155. if ftn & crash then 'Set CRASH TRUE'
  156. if ftn & nopickup then 'Set NOPICKUP TRUE'
  157. 'Call '||site_address
  158. welstat=RC
  159. if ~noclip then redial_delay=GetClip('REDIALDELAY')
  160. select
  161. when welstat=0 then do
  162.     call PutLog(site_address' OK on 'callcount);return(callok)
  163. end
  164. when welstat=1 then do
  165.     call PutLog(site_address' OWNDEVUNIT HAS LINE on 'callcount);return(retry)
  166. end
  167. when welstat=5 then do
  168.     call PutLog(site_address' BUSY on 'callcount)
  169.     call redial_pause(GetClip('BUSYDELAY'));return(retry)
  170. end
  171. when welstat=6 then do
  172.     call PutLog(site_address' NO NUMBER TO CALL on 'callcount);return(exitcall)
  173. end
  174. when welstat=7 then do
  175.     call PutLog(site_address' CALL FORWARDED on 'callcount);return(exitcall)
  176. end
  177. when welstat=10 then do
  178.     call PutLog(site_address' NO MODEM FOUND on 'callcount);return(exitcall)
  179. end
  180. when welstat=11 then do
  181.     call PutLog(site_address' NO CARRIER on 'callcount)
  182.     call redial_pause(redialdelay)
  183.     return(retry)
  184. end
  185. when welstat=12 then do
  186.     call PutLog(site_address' MODEM RESPONSE TIMEOUT on 'callcount)
  187.     call redial_pause(redialdelay)
  188.     return(retry)
  189. end
  190. when welstat=15 then do
  191.     if GetClip('IGNORENOANSWER')='FALSE' then do
  192.         call PutLog(site_address' EXIT BADLINE on 'callcount);return(exitcall)
  193.     end;else do
  194.         call PutLog(site_address' RETRY BADLINE on 'callcount)
  195.         call redial_pause(redialdelay)
  196.         return(retry)
  197.     end
  198. end
  199. when welstat=99 then do
  200.     call PutLog(site_address' EXIT BADHANDSHAKE on 'callcount);return(exitcall)
  201. end
  202. otherwise do
  203.     call PutLog('Call 'callcount' to 'site_address' Status: 'welstat);return(exitcall)
  204. end
  205. end
  206. PutLog('ERROR: FallThru Call 'callcount' to 'site_address' Status: 'welstat);return(retry)
  207. redial_pause:
  208. call PutLog('Waiting 'arg(1)' Secs Call:'site_address)
  209. call delay(arg(1)*50)
  210. return 0
  211. callcleanup:
  212. call PutLog('Removing 'site_address' from dial queue')
  213. call SetClip("S"||site_address,"")
  214. return 0
  215. make5d: procedure expose dd z n f p
  216. da=arg(1)
  217. select
  218. when index(da, "#") > 0 then parse var da dd "#" z ":" n "/" f "." p
  219. when index(da, ":") > 0 then parse var da z ":" n "/" f "." p
  220. when index(da, "/") > 0 then parse var da n "/" f "." p
  221. when index(da, ".") > 0 then parse var da f "." p
  222. when left(da, 1)="." then parse var da "." p
  223. otherwise parse var da f .
  224. end
  225. myaddress.domain=GetClip('DOMAIN')
  226. cfgaddress=GetClip('HOST.ADDRESS.'||myaddress.domain)
  227. parse var cfgaddress myaddress.zone ":" myaddress.net "/" myaddress.node "." myaddress.point
  228. if p=""|p='P' then p='0'
  229. if n=""|n='N' then n=myaddress.net
  230. if f=""|f='F' then f=myaddress.node
  231. if z=""|z='Z' then z=myaddress.zone
  232. if dd=""|dd='DD' then do
  233. dl=GetClip('DOMAINLIST');dd=0;x=find(dl,z)
  234. if x~=0 then dd=word(dl,x-1)
  235. else dd=myaddress.domain
  236. end
  237. if ~datatype(z,'n')|~datatype(n,'n')|~datatype(f,'n')|~datatype(p,'n') then
  238. do
  239. call PutLog('make5d: Invalid address ['da']')
  240. drop da;return 0
  241. end
  242. drop da
  243. return(dd'#'z':'n'/'f'.'p)
  244.  
  245. openwin:
  246. call close('STDOUT')
  247. call open('STDOUT',arg(1)||GetClip('SCREEN'),'W')
  248. call close('STDIN')
  249. call open('STDIN','*','R')
  250. return
  251.  
  252. lower:
  253. return(bitor(arg(1),'20'x))
  254.  
  255. PutLog: procedure expose lshelter ushelter slave pollwin
  256. address 'LOGPROC' 'PutLog 'lshelter'wpl' time() ushelter||slave': 'arg(1)
  257. if pollwin then say arg(1)
  258. return 0
  259.  
  260. PutStatus: procedure expose lshelter slave
  261. address 'LOGPROC' 'Putline 'lshelter'wplstat'||slave arg(1)
  262. return 0
  263.  
  264. break_c:
  265. break_d:
  266. call callcleanup()
  267. PutLog('User Aborted 'what where)
  268. cleanup:
  269. exit 0
  270. novalue:
  271. call template_oops "Novalue" sigl
  272. syntax:
  273. call template_oops "Syntax(RC=" || RC || ")" sigl RC
  274. failure:
  275. call template_oops "Failure(RC=" || RC || ")" sigl
  276. ioerr:
  277. call template_oops "IOErr(RC=" || RC || ")" sigl
  278. halt:
  279. call template_oops "Halt" sigl
  280. template_oops:
  281. parse arg what badline code
  282. if code~="" then call PutLog("ERROR LINE:"badline errortext(code))
  283.     else call PutLog("ERROR LINE:"badline what)
  284. exit(40)
  285.  
  286. usage:
  287.     say "Usage: Scall" 
  288.     say "     "template
  289.     say "       Site_Address    FTN-  [domain#][z:][net/]node[.p] CLOCK- clock<n>"
  290.     say "                       UUCP- uu<site> FAX- fax_<site> BBS- bbs_<site>"
  291.     say "       Number          phone number when manual dialing"
  292.     say "       Line            modem line to use for dialing"
  293.     say "           DEFAULT "def_line
  294.     say "       Pri             task priority for poll"
  295.     say "           DEFAULT -1"
  296.     say "       RedialDelay     number of seconds to wait between dials"
  297.     say "           DEFAULT "GetClip('REDIALDELAY')
  298.     say "       Duration        number of minutes to attempt connection"
  299.     say "           DEFAULT "GetCLip('CALLWINDOWMIN')
  300.     say "   Switches"
  301.     say "       crash           send crash mail only"
  302.     say "       nopickup        do not accept inbound files"
  303.     say
  304.